<template>
  <div id="app">
    <Topbar :key="topBarkey" />
    <Header />
    <router-view />
    <Footer />
    <Login v-show="isShowLogin" />
    <transition>
      <Toast v-show="isShowToast" />
    </transition>
  </div>
</template>
<script>
import Topbar from "./components/Topbar.vue";
import Header from "./components/Header.vue";
import Footer from "./components/Footer.vue";
// import { JingpinAPI } from "./request/api";
import Login from "./components/Login.vue";
import { mapState } from "vuex";
import Toast from "./components/Toast.vue";
export default {
  components: {
    Topbar,
    Header,
    Footer,
    Login,
    Toast,
  },
  computed: {
    ...mapState({
      // 属性：state =>state.模块名称.属性名
      isShowLogin: (state) => state.showModal.isShowLogin,
      isShowToast: (state) => state.showToast.isShowToast,
    }),
  },
  data() {
    return { topBarkey: 0 };
  },
  watch:{
    "$route.path":{
      handler(newVal,oldVal){
        if(newVal!=oldVal){
          this.topBarkey++
        }
      }
    }
  }
};
</script>

<style lang="less">
#app {
  // background-color: aqua;
}
/* 入场的起始状态 = 离场的结束状态 */
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
